Skip to content

fix: Fix acceptance tests and Delete for stream_instance acceptance tests #3447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Jun 30, 2025

Description

Fix acceptance tests and Delete for stream_processor acceptance tests.

  • Wait in Delete until stream_processor is deleted.

Link to any related issue(s): CLOUDP-328093

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@lantoli lantoli changed the title chore: Use SP10 instead of default SP30 for stream_instance acceptance tests fix: Fix acceptance tests and Delete for stream_instance acceptance tests Jul 1, 2025
@github-actions github-actions bot added the bug label Jul 1, 2025
@lantoli lantoli marked this pull request as ready for review July 1, 2025 07:35
@Copilot Copilot AI review requested due to automatic review settings July 1, 2025 07:35
@lantoli lantoli requested review from a team as code owners July 1, 2025 07:35
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes acceptance tests and improves deletion handling for stream_processor resources by waiting until the resource is fully deleted and reducing resource usage by switching to SP10.

  • Adjusted timeouts (min timeout and delay) in the state transition wait function
  • Updated acceptance tests to include a stream_config with SP10 tier
  • Modified the Delete function to wait for the resource deletion status

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/service/streamprocessor/state_transition.go Updates timeout settings in the state transition function
internal/service/streamprocessor/resource_test.go Adds stream_config with tier "SP10" for tests
internal/service/streamprocessor/resource.go Improves Delete function by waiting for deletion transition
internal/service/streamconnection/resource_stream_connection_test.go Updates test configuration with stream_config (tier SP10)
.changelog/3447.txt Adds release note for the deletion fix
Comments suppressed due to low confidence (1)

internal/service/streamprocessor/state_transition.go:35

  • [nitpick] Consider updating or expanding the nearby comment to explain the rationale behind increasing the MinTimeout and setting a Delay of 10 seconds for better clarity on the new configuration.
		MinTimeout: 10 * time.Second,

Copy link
Contributor

github-actions bot commented Jul 1, 2025

APIx bot: a message has been sent to Docs Slack channel

MinTimeout: 3 * time.Second,
Delay: 0,
MinTimeout: 10 * time.Second,
Delay: 10 * time.Second,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give some delay time to reduce flaky tests

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding 10 seconds to the delete operation of regular users for fixing our tests seems strange. Lets sync offline just to check if we can assess other options.

Copy link
Member Author

@lantoli lantoli Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, but I think this will also be helpful in Prod to fix a race condition in the API when it's under load

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me to add this 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting for Atlas team to see if this is a good approach or they would fix it in their side

Copy link
Collaborator

@oarbusi oarbusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@lantoli
Copy link
Member Author

lantoli commented Jul 1, 2025

use of SP10 instead of SP30 moved to: #3453

lantoli added 3 commits July 1, 2025 12:46
* master:
  chore: Replace fwtypes.JSONStringType with jsontypes.NormalizedType (#3452)
  chore: Use SP10 instead of default SP30 for stream_instance acceptance tests (#3453)
  chore: JSON attributes in auto-generated resources (#3445)
  chore: Updates repository to use supported Terraform versions (#3450)
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_stream_processor: Fixes Delete to wait until the resource is deleted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resource/mongodbatlas_stream_processor: Fixes Delete to wait until the resource is deleted
resource/mongodbatlas_stream_processor: Fixes Delete to wait until the resource is deleted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once we get confirmation from streams team that delete is effectively a LRO which requires followup polling

resp.Diagnostics.AddError("error deleting resource", err.Error())
return
}
_, err := WaitStateTransition(ctx, params, connV2.StreamsApi, []string{InitiatingState, CreatingState, CreatedState, StartedState, StoppedState}, []string{DroppedState})
if apiError, _ := admin.AsError(err); apiError.GetError() == http.StatusBadRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we can check for BadRequest or NotFound (what would be the correct implementation) just to be future proof

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, changed here: 2b47d75

@lantoli lantoli added the not_stale Not stale issue or PR label Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug not_stale Not stale issue or PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants